﻿
@{
    ViewBag.Title = "幼儿园管理";
}
<div class="title-content">幼儿园管理</div>


<style type="text/css">
    .td-text-center {
        text-align: center;
        /*padding-left:10px;*/
    }

    .checkbox2 {
        border: 1px solid #b2b2b2;
        box-sizing: border-box;
        height: 20px;
        width: 20px;
    }
    /*班级样式*/
    .banjitd {
        width: 150px;
        text-align: center;
    }

    .banjick {
        text-align: center;
        width: 40px;
    }
</style>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet light ">
            <div class="portlet-body">
                <div class="table-toolbar">
                    <div class="row">
                        <div class="col-md-6">
                            <!--  <div class="btn-group">
                                   <a class="btn sbold green" href="#newAdd" data-toggle="modal">新增<i class="fa fa-plus"></i></a>
                               </div>-->
                            <div class="btn-group">
                                <a class="btn sbold green" href="" onclick="plSetting(this)" data-toggle="modal">批量设置签到视频截止日期</a>
                            </div>
                            <!--  <div class="btn-group">
                                <a class="btn sbold green" href="" onclick="qianDaoMuban(this)" data-toggle="modal">批量设置接送信息模板</a>
                            </div>-->
                        </div>
                    </div>
                </div>
                <div class="dataTables_wrapper no-footer">
                    <div class="row">
                        <div class="col-md-6 col-sm-6">
                            <div class="dataTables_length" id="sample_1_length">
                                <label>
                                    显示条数 <select id="changePageSize" onchange="pageSizeChange()" class="form-control input-sm input-xsmall input-inline">
                                        <option value="10">10</option>
                                        <option value="20">20</option>
                                        <option value="50">50</option>
                                    </select>
                                </label>
                            </div>
                        </div>
                        <div class="col-md-6 col-sm-6">
                            <div id="sample_1_filter" class="dataTables_filter">
                                <label><input type="text" id="schoolInput" class="form-control input-sm input-inline" style="width:200px;" placeholder="幼儿园Id、名称" /></label>
                                <button type="button" class="btn btn-sm blue" onclick="search()">查找<i class="fa fa-search"></i></button>
                            </div>
                        </div>
                    </div>
                    <div class="table-scrollable">
                        <table class="table table-striped table-bordered table-hover order-column dataTable no-footer" role="grid" aria-describedby="sample_1_info">
                            <thead>
                                <tr role="row">
                                    <th style="width: 30px;text-align:center;"><input type="checkbox" id="ckAll" class="checkbox2" style="-webkit-appearance:checkbox;opacity:1;width:20px;height:20px;" /></th>
                                    <th style="width: 250px;">学校id </th>
                                    <th style="width: 180px;">幼儿园名称 </th>
                                    <th style="width: 110px;"> 园长姓名 </th>
                                    <th class="td-text-center" style="width:70px;"> 查看签到视频截止日期 </th>
                                    <th class="td-text-center" tabindex="0" rowspan="1" colspan="1" style="width: 157px;"> 操作设置 </th>
                                </tr>
                            </thead>
                            <tbody id="gridTable"></tbody>
                        </table>
                        <script id="grid" type="text/html">
                            <% for(var i=0;i
                            <list.length;i++){ %>
                                <% var item=list[i]; %>
                                <tr class="gradeX" role="row" id="<%=item.schoolId %>">
                                    <td class="td-text-center"><input type="checkbox" name="ckchild" schoolId="<%=item.schoolId %>" class="checkbox2"></td>
                                    <td><%=item.schoolId %></td>
                                    <td><%=item.schoolName %></td>
                                    <td name="yzName"><%=item.teacherName %></td>
                                    <td name="qvEndDate" class="td-text-center"><%=item.qvEndDate %></td>
                                    <td name="teacherId" style="display:none;"><%=item.teacherId %></td>
                                    <td name="phone" style="display:none;"><%=item.phone %></td>
                                    <td name="pwd" style="display:none;"><%=item.password %></td>
                                    <td name="status" style="display:none;"><%=item.status %></td>
                                    <td class="td-text-center">
                                        <a class="btn btn-sm green" href="#itemSettingAccount" onclick="setingInit('<%= item.schoolId %>')" data-toggle="modal">园长</a>
                                        <a class="btn btn-sm green" href="" onclick="showBanji('<%= item.schoolId %>',this)" data-toggle="modal">班级</a>
                                        <a class="btn btn-sm green" href="#editNameDiv" onclick="nameEdit('<%= item.schoolId %>')" data-toggle="modal">编辑</a>
                                    </td>
                                </tr>
                                <%}%>
                        </script>
                    </div>
                    <div class="row">
                        <div class="col-md-5 col-sm-5"><div class="dataTables_info" id="data_info">显示 1 到 10 共 0 条</div></div>
                        <div class="col-md-7 col-sm-7">
                            <!--加载分页控件-->
                            @Html.Partial("DataPager")
                        </div>
                    </div>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>
</div>

<!--幼儿园名称编辑，存储学习id-->
<input type="hidden" id="schoolNameEdit" />

<!-- 弹出层，新增-->
<div id="newAdd"  class="modal fade" tabindex="-1" data-focus-on="input:first">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">新增幼儿园</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div action="#" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputEmail1" class="col-md-4 control-label">幼儿园名称</label>
                            <div class="col-md-6">
                                <input type="text" class="form-control" id="schoolName" placeholder="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn default" data-dismiss="modal" id="addCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="add()">提交</button>
            </div> 
        </div>
</div>

<!-- 弹出层，编辑幼儿园名称-->
<div id="editNameDiv" class="modal fade" tabindex="-1" data-focus-on="input:first">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">编辑幼儿园</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div action="#" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inputEmail1" class="col-md-4 control-label">幼儿园名称</label>
                            <div class="col-md-6">
                                <input type="text" class="form-control" id="editSchoolName" placeholder="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn default" data-dismiss="modal" id="editNameCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="editName()">提交</button>
            </div>
    </div>
</div>

<!-- 弹出层，幼儿园批量设置签到视频截止日期-->
<div id="itemSetting" class="modal fade" tabindex="-1" data-focus-on="input:first" data-width="530">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">幼儿园高级功能设置</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div action="#" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="qvEndDate" class="col-md-4 control-label">查看签到视频截止日期</label>
                            <div class="col-md-6">
                                <div class="input-group input-sm date date-picker" id="qvEndDate" data-date-format="yyyy-mm-dd" data-date-end-date="">
                                    <input type="text" class="form-control" readonly="">
                                    <span class="input-group-btn">
                                        <button class="btn default" type="button">
                                            <i class="fa fa-calendar"></i>
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <div style="color:#aeaeae;float:left;">选中了<span id="yyCount"></span>个幼儿园</div>
                <button class="btn default" data-dismiss="modal" id="szCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="settingPiLiang()">提交</button>
            </div>
    </div>
</div>

<!-- 弹出层，幼儿园批量设置签到消息模板-->
<div id="setQianDao" class="modal fade" tabindex="-1" data-focus-on="input:first">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">幼儿园签到消息模板设置</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div action="#" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="xiaoximuban" class="col-md-3 control-label">签到消息模板</label>
                            <div class="col-md-8">
                                <textarea class="form-control" id="xiaoximuban" style="height:70px;"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <div style="color:#aeaeae;float:left;">选中了<span id="yyCount2"></span>个幼儿园</div>
                <button class="btn default" data-dismiss="modal" id="qianDaoCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="saveQianDaoMuBan()">提交</button>
            </div>
        </div>
</div>

<!-- 弹出层，设置园长账户-->
<div id="itemSettingAccount" class="modal fade" tabindex="-1" data-focus-on="input:first">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">园长账户设置</h4>
            </div>
            <div class="modal-body">
                <div style="margin-left:10px;">
                    <div action="#" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="yzName" class="col-md-4 control-label">园长姓名</label>
                            <div class="col-md-4">
                                <input type="text" class="form-control" id="yzName" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="yzAccount" class="col-md-4 control-label">园长登录账号</label>
                            <div class="col-md-4">
                                <input type="text" class="form-control" onkeyup="checkPhone()" id="yzAccount" placeholder="">
                            </div>
                            <div class="col-md-4" id="ckPhoneMsg" style="line-height:35px;"></div>
                        </div>
                        <div class="form-group">
                            <label for="yzPwd" class="col-md-4 control-label">园长登录密码</label>
                            <div class="col-md-4">
                                <input type="text" class="form-control" id="yzPwd" value="123456" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="yzPwd" class="col-md-4 control-label">是否可用</label>
                            <div class="col-md-4">
                                <select id="status" class="form-control">
                                    <option value="1">可用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn default" data-dismiss="modal" id="szAccCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="setingAccount()">提交</button>
        </div>
    </div>
</div>

<!-- 弹出层，设置班级的查看签到视频截止日期-->
<div id="banjiSet" class="modal fade"  tabindex="-1" data-focus-on="input:first" data-width="650"  >
        <div class="modal-content"  >
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">班级高级功能设置</h4>
            </div>
            <div class="modal-body">
                <div>
                    <div action="#" class="form-horizontal" role="form">
                        <div class="row">
                            <div class="col-md-8" style="border:0px solid black;overflow-y:auto;height:450px; width:430px">
                                <!--加载班级列表-->
                                <div style="border:0px solid #d0d0d0;">
                                    <table border="1" style="border:1px solid #dddddd;border-collapse:collapse;line-height:30px;width:100%;">
                                        <thead>
                                            <tr>
                                                <th class="banjick"><input type="checkbox" id="bjckAll" class="checkbox2" style="-webkit-appearance:checkbox;opacity:1;width:20px;height:20px;" /></th>
                                                <th >&nbsp;&nbsp;班级</th>
                                                <th class="banjitd">签到视频截止日期</th>
                                            </tr>
                                        </thead>
                                        <tbody id="banjiTBody"></tbody>
                                    </table>
                                    <div id="banjiTishi"></div>
                                    <script id="banjiTable" type="text/html">
                                        <% for(var k=0;k
                                        <data.length;k++){ %>
                                            <% var item=data[k]; %>
                                            <tr>
                                                <td class="banjick" style="padding-top:5px;"><input type="checkbox" name="bjck" class="checkbox2" classId="<%=item.Id %>" /></td>
                                                <td>&nbsp;&nbsp;<%=item.Classname %></td>
                                                <td class="banjitd"><%=item.Qvdate %></td>
                                            </tr>
                                            <% } %>
                                    </script>
                                </div>
                            </div>
                            <div class="col-md-4" style="border:0px solid blue;">
                                <div for="qvEndDate2" style="margin-bottom:5px;">签到查看截止日期</div>
                                <div style="margin-bottom:20px;">
                                    <div class="input-group input-sm date date-picker" id="qvEndDate2" data-date-format="yyyy-mm-dd" data-date-end-date="">
                                        <input type="text" class="form-control" readonly="">
                                        <span class="input-group-btn">
                                            <button class="btn default" type="button">
                                                <i class="fa fa-calendar"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn default" data-dismiss="modal" id="banJiSetCloseBtn" aria-hidden="true">关闭</button>
                <button class="btn green" data-dismiss="" onclick="banjiSetTijiao()">提交</button>
            </div>
        </div>
</div>


<script type="text/javascript">
    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            GridData();
        }
    });

    $(document).ready(function () {
        GridData();
    });

    //全选
    $("#ckAll").click(function () {
        var ckall = this;
        $("input[name=ckchild]").each(function (index, element) {
            $(element)[0].checked = ckall.checked;
        });
    });

    //编辑幼儿园名称
    function editName() {
        var schoolId = $("#schoolNameEdit").val();
        if (schoolId == undefined || schoolId == null || schoolId == "") {
            AlertMsg("幼儿园id丢失");
            return;
        }
        var schoolName = $("#editSchoolName").val().trim();
        if (schoolName == undefined || schoolName == null || schoolName == "") {
            AlertMsg("幼儿园名称不能为空");
            return;
        }
        AjaxCustom({
            url: "/School/EditSchoolName",
            type: "post",
            parames: { schoolId: schoolId, schoolName: schoolName },
            callBack: function (data) {
                $("#editNameCloseBtn").click();//隐藏弹出层
                if (data.code == 1) {
                    AlertMsg("修改成功");
                    pageIndex = 1;
                    GridData();
                } else {
                    AlertMsg("修改失败");
                }
            }
        });
    }

    //弹出编辑幼儿园名称层
    function nameEdit(schoolId) {
        $("#editSchoolName").val("");
        $("#schoolNameEdit").val(schoolId);
    }

    //查找
    function search() {
        pageIndex = 1;
        GridData();
    }
    //改变页大小
    function pageSizeChange() {
        var count = $("#changePageSize").val();
        pageSize = count;
        pageIndex = 1;
        GridData();
    }
    //查询表格数据
    function GridData() {
        var schoolName = $("#schoolInput").val().trim();
        AjaxCustom({
            url: "/School/GetSchoolList",
            type: "post",
            showLoading: true,//是否显示遮罩层
            parames: { youeryuanName: schoolName, pageIndex: pageIndex, pageSize: pageSize },
            callBack: function (obj) {
                var start = (obj.data.pageIndex - 1) * pageSize + 1;
                var end = obj.data.pageIndex * pageSize;
                $("#TotalCount").html(obj.data.total);//总行数
                if (obj.data.total == 0) {
                    $("#data_info").html("");
                    $("#gridTable").html("<tr><td colspan=\"6\" style='text-align:center;'><b style='color:red;'>暂无数据</b></td></tr>");
                    document.getElementById('paging1').innerHTML = "";//分页控件代码为空
                } else {
                    if (pageIndex == obj.data.pageCount) {
                        $("#data_info").html("显示 " + start + " 到 " + obj.data.total + " 共 " + obj.data.total + " 条");
                    } else {
                        $("#data_info").html("显示 " + start + " 到 " + end + " 共 " + obj.data.total + " 条");
                    }
                    //加载数据
                    var gridData = template('grid', obj.data);
                    $("#gridTable").html(gridData);
                    //加载分页控件
                    loadPager(obj.data.pageIndex, obj.data.pageCount);
                }
            }
        });
    }

    //新增幼儿园
    function add() {
        var schoolName = $("#schoolName").val().trim();
        if (schoolName == "") {
            AlertMsg("幼儿园名称不能为空");
            return;
        }
        AjaxCustom({
            url: "/School/AddSchool",
            type: "post",
            parames: { schoolName: schoolName },
            callBack: function (data) {
                if (data.code == "1") {
                    AlertMsg("添加成功");
                    $("#addCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                } else {
                    AlertMsg("添加失败");
                }
            }
        });
    }

    //批量设置显示弹出层
    function plSetting(thisObj) {
        $(thisObj).attr("href", "");
        var count = $("input[name=ckchild]:checked").length;
        if (count == 0) {
            AlertMsg("请至少选中一个幼儿园");
            return;
        }
        $("#qvEndDate").val("");
        $(thisObj).attr("href", "#itemSetting");//显示弹出层
        $("#yyCount").html(count);
    }

    //保存批量设置
    function settingPiLiang() {
        var qvEndDate = $("#qvEndDate").find("input").val();
        if (qvEndDate == "") {
            AlertMsg("请设置日期");
            return;
        }
        showLoading("正在保存...");
        var ids = [];
        $("input[name=ckchild]:checked").each(function (index, element) {
            var id = $(this).attr("schoolId");
            ids.push(id);
        });
        var idsTxt = ids.join(",");//选中的幼儿园id
        AjaxCustom({
            url: "/School/SettingSchool",
            type: "post",
            parames: { schoolIds: idsTxt, qvEndDate: qvEndDate },
            callBack: function (obj) {
                closeLoading();
                if (obj.code == 1) {
                    AlertMsg("设置成功");
                    $("#szCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                } else {
                    AlertMsg("设置失败");
                    $("#szCloseBtn").click();//隐藏弹出层
                }
                if ($("#ckAll")[0].checked == true) {
                    $("#ckAll")[0].checked = false;
                }
            }
        });
    }

    //点击【设置园长】
    var schoolId = "";//设置的幼儿园id
    var teacherId = "";//园长id
    var oldAccount = "";//修改前账号
    function setingInit(itemId) {
        schoolId = itemId;
        $("#ckPhoneMsg").html("");
        teacherId = $("#" + itemId).find("td[name=teacherId]").html();//园长id
        var yzName = $("#" + itemId).find("td[name=yzName]").html();//园长姓名
        var phone = $("#" + itemId).find("td[name=phone]").html();//账号
        var pwd = $("#" + itemId).find("td[name=pwd]").html();    //密码
        var status = $("#" + itemId).find("td[name=status]").html();    //可用状态
        oldAccount = phone;
        if (pwd == "") {
            pwd = "123456";
        }
        setTimeout(function () {
            $("#yzName").focus();
            $("#yzName").val(yzName);
            $("#yzAccount").val(phone);
            $("#yzPwd").val(pwd);
            if (status == null || status == "" || status == " ") {
                $("#status").val("1");
            } else {
                $("#status").val(status);
            }
        }, 200);
    }

    //幼儿园设置园长
    function setingAccount() {
        var yzAccount = $("#yzAccount").val();
        if (yzAccount == "") {
            AlertMsg("账号不能为空");
            $("#yzAccount").focus();
            return;
        }
        var pwd = $("#yzPwd").val();
        if (pwd == "") {
            AlertMsg("密码不能为空");
            $("#yzPwd").focus();
            return;
        }
        var type = "add";
        if (teacherId == "") {
            type = "add";   //新增园长
        } else {
            type = "update";//修改园长
        }
        var yzName = $("#yzName").val();
        var status = $("#status").val();
        AjaxCustom({
            url: "/School/SettingSchoolAccount",
            type: "post",
            parames: { schoolId: schoolId, yzAccount: yzAccount, yzName: yzName, pwd: pwd, type: type, teacherId: teacherId, status: status },
            callBack: function (obj) {
                if (obj.code == 1) {
                    AlertMsg("设置成功");
                    $("#szAccCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                } else if (obj.code == 9) {
                    $("#ckPhoneMsg").html(obj.data);//该账号已存在
                    $("#ckPhoneMsg").css("color", "red");
                } else {
                    AlertMsg("设置失败");
                    $("#szAccCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                }
            }
        });
    }

    //验证账号是否存在
    function checkPhone() {
        var yzAccount = $("#yzAccount").val();
        if (oldAccount == yzAccount) {
            $("#ckPhoneMsg").html("");
            return;
        }
        if (yzAccount != "") {
            AjaxCustom({
                url: "/School/CheckTeacherPhone",
                type: "post",
                parames: { phone: yzAccount, },
                callBack: function (obj) {
                    if (obj.code > 0) {
                        $("#ckPhoneMsg").html("该账号已存在");
                        $("#ckPhoneMsg").css("color", "red");
                    } else {
                        $("#ckPhoneMsg").html("账号验证通过");
                        $("#ckPhoneMsg").css("color", "green");
                    }
                }
            });
        } else {
            $("#ckPhoneMsg").html("");
        }
    }

    //显示签到模板设置
    function qianDaoMuban(thisObj) {
        $("#xiaoximuban").val("");
        $(thisObj).attr("href", "");//
        var count = $("input[name=ckchild]:checked").length;
        if (count == 0) {
            AlertMsg("请至少选中一个幼儿园");
            return;
        }
        if (count == 1) {
            var ids = [];
            $("input[name=ckchild]:checked").each(function (index, element) {
                var id = $(this).attr("schoolId");
                ids.push(id);
            });
            var schoolid = ids[0];
            //查询这个学校的签到模板
            AjaxCustom({
                url: "/School/GetSchoolQianDaoMuban",
                type: "post",
                parames: { schoolId: schoolid },
                callBack: function (obj) {
                    $("#xiaoximuban").val(obj.data);
                }
            });
        }
        $(thisObj).attr("href", "#setQianDao");//显示弹出层
        $("#yyCount2").html(count);
    }

    //保存签到消息模板
    function saveQianDaoMuBan() {
        var ids = [];
        $("input[name=ckchild]:checked").each(function (index, element) {
            var id = $(this).attr("schoolId");
            ids.push(id);
        });
        var idsTxt = ids.join(",");//选中的幼儿园id
        var muban = $("#xiaoximuban").val();
        if (muban.length > 200) {
            AlertMsg("消息模板超长");
            return;
        }
        showLoading("正在保存...");
        AjaxCustom({
            url: "/School/UpdateSchoolQianDaoMuban",
            type: "post",
            parames: { schoolIds: idsTxt, xiaoxi: muban },
            callBack: function (obj) {
                closeLoading();
                if (obj.code == 1) {
                    AlertMsg("设置成功");
                    $("#qianDaoCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                } else {
                    AlertMsg("设置失败");
                    $("#qianDaoCloseBtn").click();//隐藏弹出层
                    pageIndex = 1;
                    GridData();
                }
                if ($("#ckAll")[0].checked == true) {
                    $("#ckAll")[0].checked = false;
                }
            }
        });
    }

    //班级的签到截止日期，视频截止日期设置提交
    function banjiSetTijiao() {
        var qvEndDate2 = $("#qvEndDate2").find("input").val();
        if (qvEndDate2 == "") {
            AlertMsg("请设置日期");
            return;
        }
        if ($("input[name=bjck]:checked").length == 0) {
            AlertMsg("请至少选中一个班级");
            return;
        }
        var ids = [];
        $("input[name=bjck]:checked").each(function (index, element) {
            var id = $(this).attr("classId");
            ids.push(id);
        });
        var idsTxt = ids.join(",");//选中的幼儿园id
        AjaxCustom({
            url: "/TClass/SetBanJiQiandaoDateVideoDate",
            type: "post",
            parames: { classIds: idsTxt, qvEndDate: qvEndDate2 },
            callBack: function (obj) {
                if (obj.code == 1) {
                    AlertMsg("设置成功");
                } else {
                    AlertMsg("设置失败");
                }
                $("#banJiSetCloseBtn").click();//隐藏弹出层
                if ($("#ckAll")[0].checked == true) {
                    $("#ckAll")[0].checked = false;
                }
            }
        });
    }

    //显示班级弹出层
    function showBanji(schoolId, thisObj) {
        $("#banjiTBody").html("");
        //获取该园的签到截止日期和视频截止日期
        var qvEndDate = $("#" + schoolId).find("td[name=qvEndDate]").html();//签到截止日期
        if (qvEndDate == "") {
            AlertMsg("请先设置幼儿园的签到和视频截止日期，再来设置班级的");
            return;
        }
        $("#qvEndDate2").find("input").val(qvEndDate);
        //设置班级签到、视频日期限制，继承自幼儿园
        $('#qvEndDate2').datepicker('setEndDate', qvEndDate);

        $(thisObj).attr("href", "#banjiSet");//显示弹出层
        $("#banjiTishi").html("<div style=\"line-height:25px;\"><img src=\"/Content/img/loading.gif\"/>&nbsp;正在加载...</div>");
        //查询班级数据
        AjaxCustom({
            url: '/School/GetSchoolBanJi',
            parames: { schoolId: schoolId },
            callBack: function (obj) {
                if (obj.data.length == 0) {
                    $("#banjiTishi").html("暂无数据");
                } else {
                    //加载数据
                    $("#banjiTishi").html("");
                    var gridData = template('banjiTable', obj);
                    $("#banjiTBody").html(gridData);
                }
            }
        });
    }

    //班级全选
    $("#bjckAll").click(function () {
        var ckall = this;
        $("input[name=bjck]").each(function (index, element) {
            $(element)[0].checked = ckall.checked;
        });
    });

</script>
